home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 2003 September / PC Answers September 2003.iso / Software / freeware / pixeltoolbox / Setup.exe / Main / PixelToolbox.exe / PixelToolbox.dxr / Scripts_77_32bit gradient tools.ls < prev    next >
Encoding:
Text File  |  2002-06-08  |  17.9 KB  |  362 lines

  1. global gSize, gCast, gVariable, gFirstColor, gSecondColor, myCurrentImage, myCurrentPreview, g4bitValues
  2.  
  3. on toolGradientH32
  4.   member("state1 - " & gSize, gCast).image = member(gSize & "x" & gSize, gCast).image
  5.   startX = (the mouseH - sprite(1).left) * 2 / gVariable / 2
  6.   startY = (the mouseV - sprite(1).top) * 2 / gVariable / 2
  7.   myShape = rect(0, 0, 0, 0)
  8.   myStartImage = duplicate(member(gSize & "x" & gSize, gCast).image)
  9.   myCurrentImage = duplicate(member(gSize & "x" & gSize, gCast).image)
  10.   myCurrentPreview = duplicate(member("preview", gCast).image)
  11.   repeat while the mouseDown
  12.     myCurrentImage.copyPixels(myStartImage, myStartImage.rect, myStartImage.rect)
  13.     if (((the mouseV - sprite(1).top) * 2 / gVariable / 2) < startY) and (((the mouseH - sprite(1).left) * 2 / gVariable / 2) < startX) then
  14.       myShape = rect((the mouseH - sprite(1).left) * 2 / gVariable / 2, (the mouseV - sprite(1).top) * 2 / gVariable / 2, startX + 1, startY + 1)
  15.     else
  16.       if (((the mouseV - sprite(1).top) * 2 / gVariable / 2) < startY) and (((the mouseH - sprite(1).left) * 2 / gVariable / 2) >= startX) then
  17.         myShape = rect(startX, (the mouseV - sprite(1).top) * 2 / gVariable / 2, ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + 1, startY + 1)
  18.       else
  19.         if (((the mouseV - sprite(1).top) * 2 / gVariable / 2) >= startY) and (((the mouseH - sprite(1).left) * 2 / gVariable / 2) < startX) then
  20.           myShape = rect((the mouseH - sprite(1).left) * 2 / gVariable / 2, startY, startX + 1, ((the mouseV - sprite(1).top) * 2 / gVariable / 2) + 1)
  21.         else
  22.           if ((the mouseV - sprite(1).top) * 2 / gVariable / 2) = startY then
  23.             myShape = rect(startX, (the mouseV - sprite(1).top) * 2 / gVariable / 2, ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + 1, startY + 1)
  24.           else
  25.             if ((the mouseH - sprite(1).left) * 2 / gVariable / 2) = startX then
  26.               myShape = rect((the mouseH - sprite(1).left) * 2 / gVariable / 2, startY, startX + 1, ((the mouseV - sprite(1).top) * 2 / gVariable / 2) + 1)
  27.             else
  28.               myShape = rect(startX, startY, ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + 1, ((the mouseV - sprite(1).top) * 2 / gVariable / 2) + 1)
  29.             end if
  30.           end if
  31.         end if
  32.       end if
  33.     end if
  34.     if (myShape.width = 0) or (myShape.height = 0) then
  35.       nothing()
  36.       next repeat
  37.     end if
  38.     firstR = gFirstColor.red
  39.     firstG = gFirstColor.green
  40.     firstB = gFirstColor.blue
  41.     secondR = gSecondColor.red
  42.     secondG = gSecondColor.green
  43.     secondB = gSecondColor.blue
  44.     myShapeWidth = myShape.width
  45.     colorSpreadR = abs(firstR - secondR) + 1
  46.     colorSpreadG = abs(firstG - secondG) + 1
  47.     colorSpreadB = abs(firstB - secondB) + 1
  48.     colorStepR = colorSpreadR / float(myShapeWidth)
  49.     colorStepG = colorSpreadG / float(myShapeWidth)
  50.     colorStepB = colorSpreadB / float(myShapeWidth)
  51.     l = myShape.left
  52.     r = l + 1
  53.     cR = firstR
  54.     cG = firstG
  55.     cB = firstB
  56.     repeat while myShapeWidth > 1
  57.       myCurrentImage.fill(rect(l, myShape.top, r, myShape.bottom), [#shapeType: #rect, #lineSize: 0, #color: rgb(cR, cG, cB)])
  58.       myShapeWidth = myShapeWidth - 1
  59.       colorSpreadR = secondR - cR
  60.       colorSpreadG = secondG - cG
  61.       colorSpreadB = secondB - cB
  62.       colorStepR = colorSpreadR / float(myShapeWidth)
  63.       colorStepG = colorSpreadG / float(myShapeWidth)
  64.       colorStepB = colorSpreadB / float(myShapeWidth)
  65.       l = r
  66.       r = l + 1
  67.       cR = cR + colorStepR
  68.       cG = cG + colorStepG
  69.       cB = cB + colorStepB
  70.     end repeat
  71.     myCurrentImage.fill(rect(l, myShape.top, myShape.right, myShape.bottom), [#shapeType: #rect, #lineSize: 0, #color: rgb(cR, cG, cB)])
  72.     member(gSize & "x" & gSize, gCast).image.copyPixels(myCurrentImage, myCurrentImage.rect, myCurrentImage.rect)
  73.     updateStage()
  74.     put myShape.width.abs into field "dimension status W"
  75.     put myShape.height.abs into field "dimension status H"
  76.     fnUpdatePreview()
  77.   end repeat
  78.   sprite(35).pState = 0
  79.   sendSprite(35, #setMember)
  80.   member("state2 - " & gSize, gCast).image = member(gSize & "x" & gSize, gCast).image
  81.   myStartImage = VOID
  82.   myCurrentImage = VOID
  83.   myCurrentPreview = VOID
  84.   put EMPTY into field "dimension status W"
  85.   put EMPTY into field "dimension status H"
  86. end
  87.  
  88. on toolGradientV32
  89.   member("state1 - " & gSize, gCast).image = member(gSize & "x" & gSize, gCast).image
  90.   startX = (the mouseH - sprite(1).left) * 2 / gVariable / 2
  91.   startY = (the mouseV - sprite(1).top) * 2 / gVariable / 2
  92.   myShape = rect(0, 0, 0, 0)
  93.   myStartImage = duplicate(member(gSize & "x" & gSize, gCast).image)
  94.   myCurrentImage = duplicate(member(gSize & "x" & gSize, gCast).image)
  95.   myCurrentPreview = duplicate(member("preview", gCast).image)
  96.   repeat while the mouseDown
  97.     myCurrentImage.copyPixels(myStartImage, myStartImage.rect, myStartImage.rect)
  98.     if (((the mouseV - sprite(1).top) * 2 / gVariable / 2) < startY) and (((the mouseH - sprite(1).left) * 2 / gVariable / 2) < startX) then
  99.       myShape = rect((the mouseH - sprite(1).left) * 2 / gVariable / 2, (the mouseV - sprite(1).top) * 2 / gVariable / 2, startX + 1, startY + 1)
  100.     else
  101.       if (((the mouseV - sprite(1).top) * 2 / gVariable / 2) < startY) and (((the mouseH - sprite(1).left) * 2 / gVariable / 2) >= startX) then
  102.         myShape = rect(startX, (the mouseV - sprite(1).top) * 2 / gVariable / 2, ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + 1, startY + 1)
  103.       else
  104.         if (((the mouseV - sprite(1).top) * 2 / gVariable / 2) >= startY) and (((the mouseH - sprite(1).left) * 2 / gVariable / 2) < startX) then
  105.           myShape = rect((the mouseH - sprite(1).left) * 2 / gVariable / 2, startY, startX + 1, ((the mouseV - sprite(1).top) * 2 / gVariable / 2) + 1)
  106.         else
  107.           if ((the mouseV - sprite(1).top) * 2 / gVariable / 2) = startY then
  108.             myShape = rect(startX, (the mouseV - sprite(1).top) * 2 / gVariable / 2, ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + 1, startY + 1)
  109.           else
  110.             if ((the mouseH - sprite(1).left) * 2 / gVariable / 2) = startX then
  111.               myShape = rect((the mouseH - sprite(1).left) * 2 / gVariable / 2, startY, startX + 1, ((the mouseV - sprite(1).top) * 2 / gVariable / 2) + 1)
  112.             else
  113.               myShape = rect(startX, startY, ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + 1, ((the mouseV - sprite(1).top) * 2 / gVariable / 2) + 1)
  114.             end if
  115.           end if
  116.         end if
  117.       end if
  118.     end if
  119.     if (myShape.width = 0) or (myShape.height = 0) then
  120.       nothing()
  121.       next repeat
  122.     end if
  123.     firstR = gFirstColor.red
  124.     firstG = gFirstColor.green
  125.     firstB = gFirstColor.blue
  126.     secondR = gSecondColor.red
  127.     secondG = gSecondColor.green
  128.     secondB = gSecondColor.blue
  129.     myShapeHeight = myShape.height
  130.     colorSpreadR = abs(firstR - secondR) + 1
  131.     colorSpreadG = abs(firstG - secondG) + 1
  132.     colorSpreadB = abs(firstB - secondB) + 1
  133.     colorStepR = colorSpreadR / float(myShapeHeight)
  134.     colorStepG = colorSpreadG / float(myShapeHeight)
  135.     colorStepB = colorSpreadB / float(myShapeHeight)
  136.     t = myShape.top
  137.     b = t + 1
  138.     cR = firstR
  139.     cG = firstG
  140.     cB = firstB
  141.     repeat while myShapeHeight > 1
  142.       myCurrentImage.fill(rect(myShape.left, t, myShape.right, b), [#shapeType: #rect, #lineSize: 0, #color: rgb(cR, cG, cB)])
  143.       myShapeHeight = myShapeHeight - 1
  144.       colorSpreadR = secondR - cR
  145.       colorSpreadG = secondG - cG
  146.       colorSpreadB = secondB - cB
  147.       colorStepR = colorSpreadR / float(myShapeHeight)
  148.       colorStepG = colorSpreadG / float(myShapeHeight)
  149.       colorStepB = colorSpreadB / float(myShapeHeight)
  150.       t = b
  151.       b = t + 1
  152.       cR = cR + colorStepR
  153.       cG = cG + colorStepG
  154.       cB = cB + colorStepB
  155.     end repeat
  156.     myCurrentImage.fill(rect(myShape.left, t, myShape.right, myShape.bottom), [#shapeType: #rect, #lineSize: 0, #color: rgb(cR, cG, cB)])
  157.     member(gSize & "x" & gSize, gCast).image.copyPixels(myCurrentImage, myCurrentImage.rect, myCurrentImage.rect)
  158.     updateStage()
  159.     put myShape.width.abs into field "dimension status W"
  160.     put myShape.height.abs into field "dimension status H"
  161.     fnUpdatePreview()
  162.   end repeat
  163.   sprite(35).pState = 0
  164.   sendSprite(35, #setMember)
  165.   member("state2 - " & gSize, gCast).image = member(gSize & "x" & gSize, gCast).image
  166.   myStartImage = VOID
  167.   myCurrentImage = VOID
  168.   myCurrentPreview = VOID
  169.   put EMPTY into field "dimension status W"
  170.   put EMPTY into field "dimension status H"
  171. end
  172.  
  173. on toolGradientOval32
  174.   member("state1 - " & gSize, gCast).image = member(gSize & "x" & gSize, gCast).image
  175.   startX = (the mouseH - sprite(1).left) * 2 / gVariable / 2
  176.   startY = (the mouseV - sprite(1).top) * 2 / gVariable / 2
  177.   myShape = rect(0, 0, 0, 0)
  178.   myStartImage = duplicate(member(gSize & "x" & gSize, gCast).image)
  179.   myCurrentImage = duplicate(member(gSize & "x" & gSize, gCast).image)
  180.   myCurrentPreview = duplicate(member("preview", gCast).image)
  181.   repeat while the mouseDown
  182.     myCurrentImage.copyPixels(myStartImage, myStartImage.rect, myStartImage.rect)
  183.     if (((the mouseV - sprite(1).top) * 2 / gVariable / 2) < startY) and (((the mouseH - sprite(1).left) * 2 / gVariable / 2) < startX) then
  184.       myShape = rect((the mouseH - sprite(1).left) * 2 / gVariable / 2, (the mouseV - sprite(1).top) * 2 / gVariable / 2, startX + 1, startY + 1)
  185.     else
  186.       if (((the mouseV - sprite(1).top) * 2 / gVariable / 2) < startY) and (((the mouseH - sprite(1).left) * 2 / gVariable / 2) >= startX) then
  187.         myShape = rect(startX, (the mouseV - sprite(1).top) * 2 / gVariable / 2, ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + 1, startY + 1)
  188.       else
  189.         if (((the mouseV - sprite(1).top) * 2 / gVariable / 2) >= startY) and (((the mouseH - sprite(1).left) * 2 / gVariable / 2) < startX) then
  190.           myShape = rect((the mouseH - sprite(1).left) * 2 / gVariable / 2, startY, startX + 1, ((the mouseV - sprite(1).top) * 2 / gVariable / 2) + 1)
  191.         else
  192.           if ((the mouseV - sprite(1).top) * 2 / gVariable / 2) = startY then
  193.             myShape = rect(startX, (the mouseV - sprite(1).top) * 2 / gVariable / 2, ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + 1, startY + 1)
  194.           else
  195.             if ((the mouseH - sprite(1).left) * 2 / gVariable / 2) = startX then
  196.               myShape = rect((the mouseH - sprite(1).left) * 2 / gVariable / 2, startY, startX + 1, ((the mouseV - sprite(1).top) * 2 / gVariable / 2) + 1)
  197.             else
  198.               myShape = rect(startX, startY, ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + 1, ((the mouseV - sprite(1).top) * 2 / gVariable / 2) + 1)
  199.             end if
  200.           end if
  201.         end if
  202.       end if
  203.     end if
  204.     if (myShape.height < 3) or (myShape.width < 3) then
  205.       myCurrentImage.fill(myShape, [#shapeType: #oval, #lineSize: 0, #color: gFirstColor])
  206.       next repeat
  207.     end if
  208.     firstR = gFirstColor.red
  209.     firstG = gFirstColor.green
  210.     firstB = gFirstColor.blue
  211.     secondR = gSecondColor.red
  212.     secondG = gSecondColor.green
  213.     secondB = gSecondColor.blue
  214.     myShapeHeight = myShape.height
  215.     myShapeWidth = myShape.width
  216.     colorSpreadR = abs(firstR - secondR) + 1
  217.     colorSpreadG = abs(firstG - secondG) + 1
  218.     colorSpreadB = abs(firstB - secondB) + 1
  219.     colorStepR = ((colorSpreadR / float(myShape.height) * 2) + (colorSpreadR / float(myShape.width) * 2)) / 2
  220.     colorStepG = ((colorSpreadG / float(myShape.height) * 2) + (colorSpreadG / float(myShape.width) * 2)) / 2
  221.     colorStepB = ((colorSpreadB / float(myShape.height) * 2) + (colorSpreadB / float(myShape.width) * 2)) / 2
  222.     l = myShape.left
  223.     t = myShape.top
  224.     r = myShape.right
  225.     b = myShape.bottom
  226.     cR = firstR
  227.     cG = firstG
  228.     cB = firstB
  229.     repeat while (myShapeHeight > 2) and (myShapeWidth > 2)
  230.       myCurrentImage.fill(rect(l, t, r, b), [#shapeType: #oval, #lineSize: 0, #color: rgb(cR, cG, cB)])
  231.       myShapeHeight = myShapeHeight - 2
  232.       myShapeWidth = myShapeWidth - 2
  233.       colorSpreadR = secondR - cR
  234.       colorSpreadG = secondG - cG
  235.       colorSpreadB = secondB - cB
  236.       colorStepR = ((colorSpreadR / float(myShapeHeight) * 2) + (colorSpreadR / float(myShapeWidth) * 2)) / 2
  237.       colorStepG = ((colorSpreadG / float(myShapeHeight) * 2) + (colorSpreadG / float(myShapeWidth) * 2)) / 2
  238.       colorStepB = ((colorSpreadB / float(myShapeHeight) * 2) + (colorSpreadB / float(myShapeWidth) * 2)) / 2
  239.       l = l + 1
  240.       t = t + 1
  241.       r = r - 1
  242.       b = b - 1
  243.       cR = cR + colorStepR
  244.       cG = cG + colorStepG
  245.       cB = cB + colorStepB
  246.     end repeat
  247.     if (myShapeHeight = 1) and (myShapeWidth = 1) then
  248.       myCurrentImage.setPixel(l, t, gSecondColor)
  249.     else
  250.       myCurrentImage.fill(rect(l, t, r, b), [#shapeType: #oval, #lineSize: 0, #color: gSecondColor])
  251.     end if
  252.     member(gSize & "x" & gSize, gCast).image.copyPixels(myCurrentImage, myCurrentImage.rect, myCurrentImage.rect)
  253.     updateStage()
  254.     put myShape.width.abs into field "dimension status W"
  255.     put myShape.height.abs into field "dimension status H"
  256.     fnUpdatePreview()
  257.   end repeat
  258.   sprite(35).pState = 0
  259.   sendSprite(35, #setMember)
  260.   member("state2 - " & gSize, gCast).image = member(gSize & "x" & gSize, gCast).image
  261.   myStartImage = VOID
  262.   myCurrentImage = VOID
  263.   myCurrentPreview = VOID
  264.   put EMPTY into field "dimension status W"
  265.   put EMPTY into field "dimension status H"
  266. end
  267.  
  268. on toolGradientRect32
  269.   member("state1 - " & gSize, gCast).image = member(gSize & "x" & gSize, gCast).image
  270.   startX = (the mouseH - sprite(1).left) * 2 / gVariable / 2
  271.   startY = (the mouseV - sprite(1).top) * 2 / gVariable / 2
  272.   myShape = rect(0, 0, 0, 0)
  273.   myStartImage = duplicate(member(gSize & "x" & gSize, gCast).image)
  274.   myCurrentImage = duplicate(member(gSize & "x" & gSize, gCast).image)
  275.   myCurrentPreview = duplicate(member("preview", gCast).image)
  276.   repeat while the mouseDown
  277.     myCurrentImage.copyPixels(myStartImage, myStartImage.rect, myStartImage.rect)
  278.     if (((the mouseV - sprite(1).top) * 2 / gVariable / 2) < startY) and (((the mouseH - sprite(1).left) * 2 / gVariable / 2) < startX) then
  279.       myShape = rect((the mouseH - sprite(1).left) * 2 / gVariable / 2, (the mouseV - sprite(1).top) * 2 / gVariable / 2, startX + 1, startY + 1)
  280.     else
  281.       if (((the mouseV - sprite(1).top) * 2 / gVariable / 2) < startY) and (((the mouseH - sprite(1).left) * 2 / gVariable / 2) >= startX) then
  282.         myShape = rect(startX, (the mouseV - sprite(1).top) * 2 / gVariable / 2, ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + 1, startY + 1)
  283.       else
  284.         if (((the mouseV - sprite(1).top) * 2 / gVariable / 2) >= startY) and (((the mouseH - sprite(1).left) * 2 / gVariable / 2) < startX) then
  285.           myShape = rect((the mouseH - sprite(1).left) * 2 / gVariable / 2, startY, startX + 1, ((the mouseV - sprite(1).top) * 2 / gVariable / 2) + 1)
  286.         else
  287.           if ((the mouseV - sprite(1).top) * 2 / gVariable / 2) = startY then
  288.             myShape = rect(startX, (the mouseV - sprite(1).top) * 2 / gVariable / 2, ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + 1, startY + 1)
  289.           else
  290.             if ((the mouseH - sprite(1).left) * 2 / gVariable / 2) = startX then
  291.               myShape = rect((the mouseH - sprite(1).left) * 2 / gVariable / 2, startY, startX + 1, ((the mouseV - sprite(1).top) * 2 / gVariable / 2) + 1)
  292.             else
  293.               myShape = rect(startX, startY, ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + 1, ((the mouseV - sprite(1).top) * 2 / gVariable / 2) + 1)
  294.             end if
  295.           end if
  296.         end if
  297.       end if
  298.     end if
  299.     if (myShape.height < 3) or (myShape.width < 3) then
  300.       myCurrentImage.fill(myShape, [#shapeType: #rect, #lineSize: 0, #color: gFirstColor])
  301.       next repeat
  302.     end if
  303.     firstR = gFirstColor.red
  304.     firstG = gFirstColor.green
  305.     firstB = gFirstColor.blue
  306.     secondR = gSecondColor.red
  307.     secondG = gSecondColor.green
  308.     secondB = gSecondColor.blue
  309.     myShapeHeight = myShape.height
  310.     myShapeWidth = myShape.width
  311.     colorSpreadR = abs(firstR - secondR) + 1
  312.     colorSpreadG = abs(firstG - secondG) + 1
  313.     colorSpreadB = abs(firstB - secondB) + 1
  314.     colorStepR = ((colorSpreadR / float(myShape.height) * 2) + (colorSpreadR / float(myShape.width) * 2)) / 2
  315.     colorStepG = ((colorSpreadG / float(myShape.height) * 2) + (colorSpreadG / float(myShape.width) * 2)) / 2
  316.     colorStepB = ((colorSpreadB / float(myShape.height) * 2) + (colorSpreadB / float(myShape.width) * 2)) / 2
  317.     l = myShape.left
  318.     t = myShape.top
  319.     r = myShape.right
  320.     b = myShape.bottom
  321.     cR = firstR
  322.     cG = firstG
  323.     cB = firstB
  324.     repeat while (myShapeHeight > 2) and (myShapeWidth > 2)
  325.       myCurrentImage.fill(rect(l, t, r, b), [#shapeType: #rect, #lineSize: 0, #color: rgb(cR, cG, cB)])
  326.       myShapeHeight = myShapeHeight - 2
  327.       myShapeWidth = myShapeWidth - 2
  328.       colorSpreadR = secondR - cR
  329.       colorSpreadG = secondG - cG
  330.       colorSpreadB = secondB - cB
  331.       colorStepR = ((colorSpreadR / float(myShapeHeight) * 2) + (colorSpreadR / float(myShapeWidth) * 2)) / 2
  332.       colorStepG = ((colorSpreadG / float(myShapeHeight) * 2) + (colorSpreadG / float(myShapeWidth) * 2)) / 2
  333.       colorStepB = ((colorSpreadB / float(myShapeHeight) * 2) + (colorSpreadB / float(myShapeWidth) * 2)) / 2
  334.       l = l + 1
  335.       t = t + 1
  336.       r = r - 1
  337.       b = b - 1
  338.       cR = cR + colorStepR
  339.       cG = cG + colorStepG
  340.       cB = cB + colorStepB
  341.     end repeat
  342.     if (myShapeHeight = 1) and (myShapeWidth = 1) then
  343.       myCurrentImage.setPixel(l, t, gSecondColor)
  344.     else
  345.       myCurrentImage.fill(rect(l, t, r, b), [#shapeType: #rect, #lineSize: 0, #color: gSecondColor])
  346.     end if
  347.     member(gSize & "x" & gSize, gCast).image.copyPixels(myCurrentImage, myCurrentImage.rect, myCurrentImage.rect)
  348.     updateStage()
  349.     put myShape.width.abs into field "dimension status W"
  350.     put myShape.height.abs into field "dimension status H"
  351.     fnUpdatePreview()
  352.   end repeat
  353.   sprite(35).pState = 0
  354.   sendSprite(35, #setMember)
  355.   member("state2 - " & gSize, gCast).image = member(gSize & "x" & gSize, gCast).image
  356.   myStartImage = VOID
  357.   myCurrentImage = VOID
  358.   myCurrentPreview = VOID
  359.   put EMPTY into field "dimension status W"
  360.   put EMPTY into field "dimension status H"
  361. end
  362.